$(function(){
    //初始化
    Customer.init()
})

//客户共用函数
var Customer = {
    interface:{
        queryPage: '/customer/queryPageJSON', //用户注册接口
        departTree: '/basedata/department/queryAllListJSON', //部门树形结构接口
        queryEmployeeJsonAll: '/basedata/employee/queryEmployeeJson', //部门查询员工(拿当下所有部门)接口
        queryEmployeeJson: '/basedata/employee/queryByDepartMentCode', //部门查询员工(只拿到当前部门)接口
        addOrUpdateContact: '/customer/erpContactInformation/addOrUpdate', //联系方式的添加或者更新接口
        intentionRecords: '/customer/erpIntentionRecords/findPageJson', //意向记录分页查询接口
        intentionDetail: '/customer/erpIntentionRecords/findDetailById', //意向详情
        signDetail: '/customer/findById', //客户详情
        caseRecords: '/trademark/case/queryByPage', //商标案件记录分页查询接口
        queryEmployeePage: '/basedata/employee/queryEmployeeJson', //员工查询接口
        addAssignRecords: '/customer/erpAssignRecords/addOrUpdate', //指派添加或者更新接口接口,
        addBatchAssign: '/customer/erpAssignRecords/addBatchAssign', //指派客户批量添加接口
        assignRecords: '/customer/erpAssignRecords/findAssignPage', //跟进记录分页查询接口
        addOrUpdateIntentional: '/customer/erpIntentionRecords/addOrUpdateIntentions', //意向客户添加或者更新
        followRecords: '/customer/erpFollowRecords/findPageJson', //跟进记录分页查询接口
        accountDetail: '/account/queryAccountDetail', //当前登录帐号信息接口
        addOrUpdateFollowRecords: '/customer/erpFollowRecords/addOrUpdate', //跟进记录添加或者更新接口
        intentionLabel: '/basedata/erpIntentionLabel/findAll', //请求意向标签接口
        contactInfo: '/customer/erpContactInformation/queryAll', //客户联系方式列表接口
        invoiceInfo: '/customer/erpInvoiceHeaderManage/findAll', //客户发票抬头列表接口
        checkEnterprises: '/customer/saveEnterpriseQueryCustomer', //根据企业全名查询并保存客户信息接口
        certificateRecords: '/customer/erpCustomerDoc/findListByCustId', //客户证件证照列表接口
        addOrUpdateCertificate: '/customer/erpCustomerDoc/addOrUpdate', //证件证照添加更新接口
        addOrUpdateCustomer: '/customer/addOrUpdate', //客户添加更新接口
        findIndustryBySearch: '/customer/findIndustryBySearch', //所在行业根据名称模糊查询接口
        potentialRecords: '/customer/erpPotentialCustomer/findPageJson', //潜在客户分页查询接口
        potentialDetail: '/customer/erpPotentialCustomer/findDetail', //潜在详情
        addOrUpdatePotential: '/customer/erpPotentialCustomer/addOrUpdate', //潜在客户分页查询接口
        deleteBatchPotential: '/customer/erpPotentialCustomer/delete', //潜在客户批量删除
        deleteBatchIntention: '/customer/erpIntentionRecords/deleteBatch', //意向客户批量删除
        importBatchPotential: '/customer/erpPotentialCustomer/excelImportPotential', //潜在客户批量导入接口



        dictList: '/finance/erpAccountReceivable/querydictionDetailListByCode', //数据词典接口
    },
    //数据词典code
    dictCode:[
        'contactsType', // 0 联系人类型
        'licenseType', // 1 证照类型
        'followupWay', // 2 跟进方式
        'followupReason', // 3 跟进事由
        'entrepreneurial', //4 公司类型
        'enterpriseAppearance', //5 经营状况
    ],
    init:function(){

    },
    //通用axios请求
    axiosRequest:function(url,param,successCb,option){
        /**
         * 请求配置项
         * @option.type  GET 默认
         * @option.filterParam  false 默认保留空值或0 ,true 不保留空值或0
         */
        option = option==undefined?{}: option;
        axios({
            method: option.type==undefined?'GET': option.type,
            url: url,
            data: VUE_UTIL.buildPostFormData(param,option.noFilter)
        }).then(function (response) {
            var result = response.data;
            successCb(result);
        }).catch(function (error) {
            console.log(error);
        });
    },
    //添加联系人（沿用ERP1.0版本）
    contactFunction:function(param,_selector,isRun){
        /*Arg Guide
         @param  Object  {
                    types: 0,     //0：意向，1:签约 2 潜在
           }
         @_selector: 对象选择器
         */
        Customer.verifier('.file-verifier');
        var addContact = {
            ele: _selector,
            addContact: '.add-btn',//点击添加联系人
            closeAdd: 'dt .icon.remove',//添加联系人区域点击关闭编辑
            confirmAdd: 'dt .icon.checkmark',//添加联系人区域点击确认编辑
            editContact: 'dd .icon.edit',//编辑联系人区域点击编辑
            deleteContact: 'dd .icon.trash',//编辑联系人区域点击删除
            editConfirm: 'dd .icon.checkmark',//编辑联系人区域点击确认
            editClose: 'dd .icon.remove',//编辑联系人区域点击关闭
            gainDistBtn: _selector + ' #contactsType' //获取数据词典
        }
        var $cloneHtml;
        //获取数据词典联系人类型
        //联系人类型
        $.get('/finance/erpAccountReceivable/querydictionDetailListByCode?code=contactsType',
            function (result) {
                var $options = '<option value="">请选择</option>';
                if (result.code == 0) {
                    var _data = result.data;
                    _data.forEach(function (val) {
                        $options += '<option value="' + val.dictionaryDetailKey + '">'
                            + val.dictionaryDetailName + '</option>';
                    })
                }
                else if (result.code == 9999) {
                    layer.msg(result.msg, {time: 1000});
                    wzERP.Common.TimeoutLogin();
                    return false;
                }
                $(addContact.gainDistBtn).empty().append($options);
            });
        //事件化
        if (isRun) {
            addContactCard(addContact);
        }
        function addContactCard(_option) {
            var selector = $(_option.ele);
            //点击添加联系人
            selector.on('click', _option.addContact, function () {
                $(this).hide();
                $(this).siblings('.contact-edit').show();
                if (!$cloneHtml) {
                    $cloneHtml = $(this).siblings('.contact-edit').html();
                }
            })
            //添加联系人区域点击关闭编辑
            selector.on('click', _option.closeAdd, function () {
                $(this).parents('.contact-edit').hide()
                    .siblings('.add-btn').show();
            })
            //添加联系人区域点击确认编辑
            selector.on('click', _option.confirmAdd, function () {
                var $form = $(this).parents('.contact-edit');
                //输入不规范返回
                $form.find('form').form('submit');
                if ($form.find('form').hasClass('error')) {
                    //提示错误信息
                    var erroMsg = $form.find('form').find('.ui.field.error').eq(0).find('.ui.basic.red.label').text();
                    layer.msg(erroMsg,{time:1000})
                    return false;
                }
                //ajax添加
                var content = $form.find('.add-contact-form').serialize();
                var content = decodeURIComponent(content, true);
                var contentS = content.split('&')
                var formObj = {}
                for (var i = 0; i < contentS.length; i++) {
                    var con = contentS[i].toString()
                    var son = con.split('=')
                    formObj[son[0]] = son[1]
                }
                //其他信息表单增属性
                formObj['custId'] = parseInt($('#faswcd').val());
                formObj['types'] = param.types;
                console.log(formObj)
                $.ajax({
                    type: "POST",
                    url: '/customer/erpContactInformation/addOrUpdate',
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(formObj),
                    success: function (result) {
                        console.log('联系人添加上传', result.msg);
                        if (result.code == 0) {
                            var getId = result.data.id;
                            layer.msg('添加并保存成功!', {time: 1000});
                            selector.find('dt').append(
                                '<div class="contact-edit editing-state">' + $cloneHtml
                                + '</div>');//添加新的dom
                            //赋值
                            $form.find('.inline.fields').each(function () {
                                var $this = $(this);
                                var $select = $this.find('select');
                                var $inputText = $this.find('input.prompt');
                                var $textarea = $this.find('textarea');
                                var $calendar = $this.find('.calendar.single-date');
                                var $checkbox = $this.find('.checkbox.checked');
                                var $val = $this.find('.val');
                                if ($select.length > 0) {
                                    if ($select.find('option:selected').text() == '请选择') {
                                        $val.text('');
                                    } else {
                                        $val.text($select.find('option:selected').text());
                                    }
                                } else if ($inputText.length > 0) {
                                    $val.text($inputText.val());
                                } else if ($textarea.length > 0) {
                                    $val.text($textarea.val());
                                } else if ($checkbox.length > 0) {
                                    var text = '';
                                    if ($calendar.length > 0) {
                                        if ($calendar.find('input').val() == '') {
                                            return true
                                        }
                                        text += $calendar.find('input').val();
                                    }
                                    text += '  ';
                                    text += $checkbox.find('label').text();
                                    $val.text(text);
                                }
                            });
                            //位置处理
                            $form.siblings('.add-btn').show();
                            $form.removeClass('editing-state').attr('data-id', getId);
                            $form.find('h2 .act-state').text('编辑联系人');
                            $form.find('h2 .form-head').text(formObj['contactName']);
                            selector.find('dt').after('<dd></dd>');
                            selector.find('dd').eq(0).prepend($form);
                            //对新增的dom重新添加事件
                            var $new = selector.find('dt').find('.contact-edit');
                            $new.hide();
                            $new.find('.ui.checkbox').checkbox();
                            $new.find('.ui.dropdown').dropdown();
                            Customer.verifier(_option.ele + ' dt .file-verifier');
                            //单个日期
                            wzERP.Common.singleDate('.single-date');
                        }
                        else if (result.code == 9999) {
                            layer.msg(result.msg, {time: 1000});
                            wzERP.Common.TimeoutLogin();
                            return false;
                        }
                        else {
                            layer.msg('添加失败!', {time: 1000});
                        }
                    }
                });
            });
            //编辑联系人区域点击编辑
            selector.on('click', _option.editContact, function () {
                var $parent = $(this).parents('.contact-edit');
                $parent.addClass('editing-state');
                //处理数据词典选中状态
                var $selected = $parent.find('.select-ui-box .selection .text');
                if ($selected.length > 0) {
                    var selectText = $selected.text();
                    $parent.find('#contactsType option').each(function () {
                        if ($(this).text() == selectText) {
                            $(this).attr('selected', true);
                        }
                        console.log(selectText, $(this).text())
                    })
                }
                $('.ui.checkbox').checkbox();
                //重新调一次时间组件
                wzERP.Common.singleDate('.single-date');
            });
            //编辑联系人区域点击确认
            selector.on('click', _option.editConfirm, function () {
                var $form = $(this).parents('.contact-edit');
                var id = $form.data('id');
                debugger
                //输入不规范返回
                Customer.verifier($form.find('form')[0]);
                $form.find('form').form('submit');
                if ($form.find('form').hasClass('error')) {
                    //提示错误信息
                    var erroMsg = $form.find('form').find('.ui.field.error').eq(0).find('.ui.basic.red.label').text();
                    layer.msg(erroMsg,{time:1000})
                    return false;
                }

                //ajax添加
                var content = $form.find('.add-contact-form').serialize();
                var content = decodeURIComponent(content, true);
                var contentS = content.split('&')
                var formObj = {}
                for (var i = 0; i < contentS.length; i++) {
                    var con = contentS[i].toString()
                    var son = con.split('=')
                    formObj[son[0]] = son[1]
                }
                //其他信息表单增属性
                formObj['custId'] = parseInt($('#faswcd').val());
                formObj['types'] = param.types;
                formObj['id'] = id;
                console.log(formObj)
                $.ajax({
                    type: "POST",
                    url: '/customer/erpContactInformation/addOrUpdate',
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(formObj),
                    success: function (result) {
                        if (result.code == 0) {
                            layer.msg('修改成功!', {time: 1000});
                            $form.find('h2 .form-head').text(formObj['contactName']);
                        }
                        else if (result.code == 9999) {
                            layer.msg(result.msg, {time: 1000});
                            wzERP.Common.TimeoutLogin();
                            return false;
                        }
                    }
                })
                $(this).parents('.contact-edit').removeClass('editing-state');
                //赋值
                $form.find('.inline.fields').each(function () {
                    var $this = $(this);
                    var $select = $this.find('select');
                    var $inputText = $this.find('input.prompt');
                    var $textarea = $this.find('textarea');
                    var $calendar = $this.find('.calendar.single-date');
                    var $checkbox = $this.find('.checkbox.checked');
                    var $val = $this.find('.val');
                    if ($select.length > 0) {
                        if ($select.find('option:selected').text() == '请选择') {
                            $val.text('');
                        } else {
                            $val.text($select.find('option:selected').text());
                        }
                    } else if ($inputText.length > 0) {
                        $val.text($inputText.val());
                    } else if ($textarea.length > 0) {
                        $val.text($textarea.val());
                    } else if ($checkbox.length > 0) {
                        var text = '';
                        if ($calendar.length > 0) {
                            if ($calendar.find('input').val() == '') {
                                return true
                            }
                            text += $calendar.find('input').val();
                        }
                        text += '  ';
                        text += $checkbox.find('label').text();
                        $val.text(text);
                    }
                });
            });
            //编辑联系人区域点击关闭
            selector.on('click', _option.editClose, function () {
                $(this).parents('.contact-edit').removeClass('editing-state');
            });
            //编辑联系人区域点击删除
            selector.on('click', _option.deleteContact, function () {
                var $this = $(this);
                var id = $(this).parents('.contact-edit').data('id');
                layer.confirm('确定删除该联系人吗？',
                    {
                        title: '提示信息',
                        btn: ['取消', '确定'] //按钮
                    },
                    //取消事件
                    function (index) {
                        layer.close(index);
                    },
                    //确认事件
                    function () {
                        $.post('/customer/erpContactInformation/delete', {id: id},
                            function (result) {
                                if (result.code == 0) {
                                    layer.msg('删除成功!', {time: 1000});
                                    //
                                    $this.parents('dd').remove();
                                }
                                else if (result.code == 9999) {
                                    layer.msg(result.msg, {time: 1000});
                                    wzERP.Common.TimeoutLogin();
                                    return false;
                                }
                                else {
                                    layer.msg('删除失败!', {time: 1000});
                                }
                            });
                    });
            });
        }
    },
    //发票抬头功能模块（沿用ERP1.0版本）
    invoiceFunction:function(_selector, isRun) {
    /*Arg Guide
     @_selector: 对象选择器
     */
    //添加抬头功能-Start
    var addInvoice = {
        ele: _selector,
        addInvoice: '.add-btn',//点击添加抬头
        closeAdd: 'dt .icon.remove',//添加抬头区域点击关闭编辑
        confirmAdd: 'dt .icon.checkmark',//添加抬头区域点击确认编辑
        editInvoice: 'dd .icon.edit',//编辑抬头区域点击编辑
        deleteInvoice: 'dd .icon.trash',//编辑抬头区域点击删除
        editConfirm: 'dd .icon.checkmark',//编辑抬头区域点击确认
        editClose: 'dd .icon.remove',//编辑抬头区域点击关闭
        actTaxZone: '.actFuncTax'//一般纳税人radio必填切换
    }
    var $cloneHtml;
    //事件化
    if (isRun) {
        addInvoiceTitle(addInvoice);
    }
    function addInvoiceTitle(_option) {
        var selector = $(_option.ele);
        //点击添加抬头
        selector.on('click', _option.addInvoice, function () {
            $(this).hide();
            $(this).siblings('.invoice-edit').show();
            if (!$cloneHtml) {
                $cloneHtml = $(this).siblings('.invoice-edit').html();
            }
            //
            $('.ui.isdefault.checkbox').checkbox()
        });
        //添加抬头区域点击关闭编辑
        selector.on('click', _option.closeAdd, function () {
            $(this).parents('.invoice-edit').hide()
                .siblings('.add-btn').show();
        });
        //添加抬头区域点击确认编辑
        selector.on('click', _option.confirmAdd, function () {
            var $form = $(this).parents('.invoice-edit');
            //输入不规范返回
            Customer.verifier($form.find('form')[0]);
            $form.find('form').form('submit');
            if ($form.find('form').hasClass('error')) {
                //提示错误信息
                var erroMsg = $form.find('form').find('.ui.field.error').eq(0).find('.ui.basic.red.label').text();
                layer.msg(erroMsg,{time:1000})
                return false;
            }
            //ajax添加
            var content = $form.find('.add-invotit-form').serialize();
            var content = decodeURIComponent(content, true);
            var contentS = content.split('&')
            var formObj = {}
            for (var i = 0; i < contentS.length; i++) {
                var con = contentS[i].toString()
                var son = con.split('=')
                formObj[son[0]] = son[1]
            }
            //其他信息表单增属性
            formObj['custId'] = parseInt($('#faswcd').val());

            if (!!formObj['isDefault'] && formObj['isDefault'] == 'on') {
                formObj['isDefault'] = 1;
            } else {
                formObj['isDefault'] = 0;
            }
            console.log(formObj)
            $.ajax({
                type: "POST",
                url: '/customer/erpInvoiceHeaderManage/addOrUpdate',
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(formObj),
                success: function (result) {
                    console.log('发票抬头添加上传', result.msg);
                    if (result.code == 0) {
                        var getId = result.data.id;
                        layer.msg('添加成功!', {time: 1000});
                        selector.find('dt').append(
                            '<div class="invoice-edit editing-state">' + $cloneHtml
                            + '</div>');//添加新的dom
                        //赋值
                        $form.find('.inline.fields').each(function () {
                            var $this = $(this);
                            var $select = $this.find('select');
                            var $inputText = $this.find('input.prompt');
                            var $textarea = $this.find('textarea');
                            var $calendar = $this.find('.calendar.single-date');
                            var $checkbox = $this.find('.checkbox.checked');
                            var $val = $this.find('.val');
                            if ($select.length > 0) {
                                $val.text($select.val());
                            } else if ($inputText.length > 0) {
                                $val.text($inputText.val());
                            } else if ($textarea.length > 0) {
                                $val.text($textarea.val());
                            } else if ($checkbox.length > 0) {
                                var text = '';
                                if ($calendar.length > 0) {
                                    text += $calendar.find('input').val();
                                }
                                text += '  ';
                                text += $checkbox.find('label').text();
                                $val.text(text);
                            }
                        });
                        //位置处理
                        $form.siblings('.add-btn').show();
                        $form.removeClass('editing-state').attr('data-id', getId);
                        var tit = $form.find('input[name="abbreName"]').val();
                        $form.find('h2 .act-state').text('编辑抬头');
                        $form.find('h2 .form-head').text(formObj['abbreName']);
                        $form.find('.ui.checkbox').off('click');
                        selector.find('dt').after('<dd></dd>');
                        selector.find('dd').eq(0).prepend($form);
                        //对新增的dom重新添加事件
                        var $new = selector.find('dt').find('.invoice-edit');
                        $new.hide();
                        $new.find('.ui.radio.checkbox').checkbox();
                        $new.find('.ui.dropdown').dropdown();
                        Customer.verifier(_option.ele + ' dt .file-verifier');
                        //单个日期
                        wzERP.Common.singleDate('.single-date');
                    }
                    else if (result.code == 9999) {
                        layer.msg(result.msg, {time: 1000});
                        wzERP.Common.TimeoutLogin();
                        return false;
                    }
                    else {
                        layer.msg('添加失败!', {time: 1000});
                    }
                }
            });
        });
        //编辑抬头区域点击编辑
        selector.on('click', _option.editInvoice, function () {
            $(this).parents('.invoice-edit').addClass('editing-state');
            $(this).parents('.invoice-edit').find('.ui.checkbox').checkbox();
        });
        //编辑抬头区域点击确认
        selector.on('click', _option.editConfirm, function () {
            var $form = $(this).parents('.invoice-edit');
            $form.find('.ui.checkbox').off('click');//查看模式不可点
            var id = $form.data('id');
            //输入不规范返回
            Customer.verifier($form.find('form')[0]);
            $form.find('form').form('submit');
            if ($form.find('form').hasClass('error')) {
                //提示错误信息
                var erroMsg = $form.find('form').find('.ui.field.error').eq(0).find('.ui.basic.red.label').text();
                layer.msg(erroMsg,{time:1000})
                return false;
            }
            //ajax添加
            var content = $form.find('.add-invotit-form').serialize();
            var content = decodeURIComponent(content, true);
            var contentS = content.split('&')
            var formObj = {}
            for (var i = 0; i < contentS.length; i++) {
                var con = contentS[i].toString()
                var son = con.split('=')
                formObj[son[0]] = son[1]
            }
            //其他信息表单增属性
            formObj['custId'] = parseInt($('#faswcd').val());

            formObj['id'] = id;
            if (!!formObj['isDefault'] && formObj['isDefault'] == 'on') {
                formObj['isDefault'] = 1;
            } else {
                formObj['isDefault'] = 0;
            }
            console.log(formObj)
            $.ajax({
                type: "POST",
                url: '/customer/erpInvoiceHeaderManage/addOrUpdate',
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(formObj),
                success: function (result) {
                    if (result.code == 0) {
                        layer.msg('修改成功!', {time: 1000});
                        $form.find('h2 .form-head').text(formObj['abbreName']);
                    }
                    else if (result.code == 9999) {
                        layer.msg(result.msg, {time: 1000});
                        wzERP.Common.TimeoutLogin();
                        return false;
                    } else {
                        layer.msg(result.msg, {time: 1000});
                    }
                }
            })
            $(this).parents('.invoice-edit').removeClass('editing-state');
            //赋值
            $form.find('.inline.fields').each(function () {
                var $this = $(this);
                var $select = $this.find('select');
                var $inputText = $this.find('input.prompt');
                var $textarea = $this.find('textarea');
                var $calendar = $this.find('.calendar.single-date');
                var $checkbox = $this.find('.checkbox.checked');
                var $val = $this.find('.val');
                if ($select.length > 0) {
                    $val.text($select.val());
                } else if ($inputText.length > 0) {
                    $val.text($inputText.val());
                } else if ($textarea.length > 0) {
                    $val.text($textarea.val());
                } else if ($checkbox.length > 0) {
                    var text = '';
                    if ($calendar.length > 0) {
                        text += $calendar.find('input').val();
                    }
                    text += '  ';
                    text += $checkbox.find('label').text();
                    $val.text(text);
                }
            });
        });
        //编辑抬头区域点击关闭
        selector.on('click', _option.editClose, function () {
            $(this).parents('.invoice-edit').removeClass('editing-state');
            $(this).parents('.invoice-edit').find('.ui.checkbox').off('click');//查看模式不可点
        });
        //编辑抬头区域点击删除
        selector.on('click', _option.deleteInvoice, function () {
            var $this = $(this);
            var id = $(this).parents('.invoice-edit').data('id');
            layer.confirm('是否确认删除该抬头？',
                {
                    title: '提示信息',
                    btn: ['取消', '确定'] //按钮
                },
                //取消事件
                function (index) {
                    layer.close(index);
                },
                //确认事件
                function () {
                    $.post('/customer/erpInvoiceHeaderManage/delete', {id: id},
                        function (result) {
                            if (result.code == 0) {
                                layer.msg('删除成功!', {time: 1000});
                                //
                                $this.parents('dd').remove();
                            }
                            else if (result.code == 9999) {
                                layer.msg(result.msg, {time: 1000});
                                wzERP.Common.TimeoutLogin();
                                return false;
                            }
                            else {
                                layer.msg('删除失败!', {time: 1000});
                            }
                        });
                });
        });
        //一般纳税人切换必填

        selector.on('click', '.actFuncTax.field', function () {
            var type = $(this).find('input[type="radio"]').val();
            var $parent = $(this).parents('.invoice-edit');
            var $vform = $(this).parents('.file-verifier');
            var actArr = ['openBank', 'accountBank', 'registAddr'];
            switch (type) {
                case '0':
                    //否
                    actArr.forEach(function (value) {
                        $parent.find('input[name="' + value + '"]').parents(
                            '.inline.fields').removeClass('required');
                        $parent.find('input[name="' + value + '"]').parent(
                            '.ui.input').removeClass('error');
                        Customer.verifier($vform[0]);
                    })
                    break;
                case '1':
                    //是
                    actArr.forEach(function (value) {
                        $parent.find('input[name="' + value + '"]').parents(
                            '.inline.fields').addClass('required');
                        Customer.verifierForHeader($vform[0]);
                    })
                    break;
                default:
                    return false;
            }
        })
    }

    //默认查看模式禁止checkbox
    $(_selector).find('dd .ui.checkbox').off('click');
    //添加抬头功能-End
},
    //表单验证器
    verifier: function (_selector) {
        /*Arg Guide
         @_selector: 对象选择器
         */
        $(_selector).form({
            on: 'blur',
            inline: true,
            transition: 'fade',
            fields: {
                //公司名称
                companyName: {
                    identifier: 'companyName',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入名称'
                    },
                        {
                            type: 'regExp[/^.{0,50}$/]',
                            prompt: '(公司名称)限制50字'
                        }]
                },
                //联系电话
                contactNumber: {
                    identifier: 'contactNumber',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入联系电话'
                    },
                        {
                            type: 'regExp[/^[0-9-]{0,20}$/]',
                            prompt: '(联系电话)只能输入数字及-，字数限制20字'
                        }]
                },
                //手机号码
                /*phoneNumber: {
                    identifier: 'phoneNumber',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入联系电话'
                    },
                        {
                            type: 'regExp[/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/]',
                            prompt: '请输入正确的手机号码'
                        }]
                },*/
                //手机号码
                phoneNumber: {
                    identifier: 'phoneNumber',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入联系电话'
                    },
                        {
                            type: 'regExp[/^[0-9-]{0,20}$/]',
                            prompt: '(手机号码)只能输入数字及-，字数限制20字'
                        }]
                },
                //联系人类型
                contactType: {
                    identifier: 'contactType',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入联系人类型'
                    }]
                },
                //联系传真
                fax: {
                    identifier: 'fax',
                    rules: [{
                        type: 'regExp[/^[0-9-]{0,20}$/]',
                        prompt: '(联系传真)只能输入数字及-，字数限制20字'
                    }]
                },
                //邮箱
                emailAddress: {
                    identifier: 'emailAddress',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入邮箱地址'
                    }, {
                        type: 'regExp[/^([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+\\.[a-zA-Z]{2,3}$/]',
                        prompt: '请输入正确的邮箱格式'
                    }, {
                        type: 'regExp[/^.{0,30}$/]',
                        prompt: '限制30字'
                    }]
                },
                //网址
                corporateLink: {
                    identifier: 'corporateLink',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,30}$/]',
                        prompt: '限制30字'
                    }, {
                        type: 'url',
                        prompt: '请输入正确的网址格式'
                    }]
                },
                //联系地址
                detailAddr: {
                    identifier: 'detailAddr',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入联系地址'
                    }, {
                        type: 'regExp[/^.{0,50}$/]',
                        prompt: '(联系地址)限制50字'
                    }]
                },
                //统一信用代码证
                creditCode: {
                    identifier: 'creditCode',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[a-zA-Z0-9]{18}$/]',
                        prompt: '(统一信用代码证)18位数字或字母'
                    }]
                },
                //营业执照
                businessLicense: {
                    identifier: 'businessLicense',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[a-zA-Z0-9]{15,18}$/]',
                        prompt: '(营业执照)限15-18位数字或字母'
                    }]
                },
                //注册号
                registrationNumber: {
                    identifier: 'registrationNumber',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[a-zA-Z0-9]{15,18}$/]',
                        prompt: '(注册号)限15-18位数字或字母'
                    }]
                },
                //组织机构代码证
                organizationCode: {
                    identifier: 'organizationCode',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[a-zA-Z0-9-]{10}$/]',
                        prompt: '(组织机构代码证)10位数字或字母(可包含一个-)'
                    }]
                },
                //税务登记证
                taxRegistrationCertificate: {
                    identifier: 'taxRegistrationCertificate',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[a-zA-Z0-9]{15}$/]',
                        prompt: '(税务登记证)15位数字或字母'
                    }]
                },
                //企业法人
                enterpriseLegalPerson: {
                    identifier: 'enterpriseLegalPerson',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(企业法人)限制20字'
                    }]
                },
                //法人身份证
                legalPersonCard: {
                    identifier: 'legalPersonCard',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[a-zA-Z0-9]{18}$/]',
                        prompt: '(法人身份证)18位数字或字母'
                    }]
                },
                //开户银行
                openAccountBank: {
                    identifier: 'openAccountBank',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(开户银行)限制20字'
                    }]
                },
                //银行账号
                accountBank: {
                    identifier: 'accountBank',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d{16,19}$/]',
                        prompt: '(银行账号)限16到19位数字'
                    }]
                },
                //注册资本
                registeredCapital: {
                    identifier: 'registeredCapitalValidate',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(注册资本)最多两位有效小数'
                    }]
                },
                //注册地址
                registAddr: {
                    identifier: 'registAddr',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,50}$/]',
                        prompt: '(注册地址)限制50字'
                    }]
                },
                //登记开关
                registAuthority: {
                    identifier: 'registAuthority',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,50}$/]',
                        prompt: '(登记开关)限制50字'
                    }]
                },
                //英文名称
                englishName: {
                    identifier: 'englishName',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,50}$/]',
                        prompt: '(英文名称)限制50字'
                    }]
                },
                //英文地址
                englishAddr: {
                    identifier: 'englishAddr',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,50}$/]',
                        prompt: '(英文地址)限制50字'
                    }]
                },
                //邮编
                custPostCode: {
                    identifier: 'custPostCode',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d{0,10}$/]',
                        prompt: '(邮编)限10位数字'
                    }]
                },
                //经营场所
                placeBusiness: {
                    identifier: 'placeBusiness',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(经营场所)限制20字'
                    }]
                },
                //经营范围
                scopeBusiness: {
                    identifier: 'scopeBusiness',
                    rules: [{
                        type: 'regExp[/^[^]{0,1000}$/]',
                        prompt: '(经营范围)长度1000字以内'
                    }]
                },
                //企业发展史
                corporateHistory: {
                    identifier: 'corporateHistory',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[^]{0,1000}$/]',
                        prompt: '(企业发展史)长度1000字以内'
                    }]
                },
                //经营理念
                managementIdea: {
                    identifier: 'managementIdea',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[^]{0,1000}$/]',
                        prompt: '(经营理念)长度1000字以内'
                    }]
                },
                //企业文化
                corporateCulture: {
                    identifier: 'corporateCulture',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[^]{0,1000}$/]',
                        prompt: '(企业文化)长度1000字以内'
                    }]
                },
                //数据报表
                //年营业收入(万元)
                annualOperatingIncome: {
                    identifier: 'annualOperatingIncome',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(年营业收入)最多两位有效小数'
                    }]
                },
                //年销售收入(万元)
                annualSalesIncome: {
                    identifier: 'annualSalesIncome',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(年销售收入)最多两位有效小数'
                    }]
                },
                //年产值(万元)
                annualOutputValue: {
                    identifier: 'annualOutputValue',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(年产值)最多两位有效小数'
                    }]
                },
                //利润(万元)
                profit: {
                    identifier: 'profit',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(利润)最多两位有效小数'
                    }]
                },
                //净利润(万元)
                netProfit: {
                    identifier: 'netProfit',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(净利润)最多两位有效小数'
                    }]
                },
                //年开票金额(万元)
                annualInvoiceAmount: {
                    identifier: 'annualInvoiceAmount',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(年开票金额)最多两位有效小数'
                    }]
                },
                //纳税总额(万元)
                totalTax: {
                    identifier: 'totalTax',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(纳税总额)最多两位有效小数'
                    }]
                },
                //年出口额(万元)
                annualExportVolume: {
                    identifier: 'annualExportVolume',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(年出口额)最多两位有效小数'
                    }]
                },
                //研发投入（万元）
                rdMoney: {
                    identifier: 'rdMoney',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d+(?:\\.\\d{1,2})?$/]',
                        prompt: '(研发投入)最多两位有效小数'
                    }]
                },
                //研发人数（人）
                rdNumber: {
                    identifier: 'rdNumber',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d*$/]',
                        prompt: '(研发人数)请输入数字'
                    }]
                },
                //企业人数（人）
                numberEnterprises: {
                    identifier: 'numberEnterprises',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d*$/]',
                        prompt: '(企业人数)请输入数字'
                    }]
                },
                //其它信息
                //社保缴纳人数
                socialSecurityNum: {
                    identifier: 'socialSecurityNum',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d{0,10}$/]',
                        prompt: '(社保缴纳人数)限10位数字'
                    }]
                },
                //大专以上学历人数
                education: {
                    identifier: 'education',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^\\d*$/]',
                        prompt: '(大专以上学历人数)请数入数字'
                    }]
                },
                //设备软件现值
                deviceSoftware: {
                    identifier: 'deviceSoftware',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(设备软件现值)限20字'
                    }]
                },
                //高新产品种类
                highTechProducts: {
                    identifier: 'highTechProducts',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[^]{0,500}$/]',
                        prompt: '(高新产品种类)限500字'
                    }]
                },
                //销售模式
                salesModel: {
                    identifier: 'salesModel',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[^]{0,500}$/]',
                        prompt: '(销售模式)限500字'
                    }]
                },
                //主营产品
                mainProducts: {
                    identifier: 'mainProducts',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[^]{0,500}$/]',
                        prompt: '(主营产品)限500字'
                    }]
                },
                //添加联系人
                contactName: {
                    identifier: 'contactName',
                    rules: [
                        {
                            type: 'empty',
                            prompt: '请输入姓名'
                        }, {
                            type: 'regExp[/^.{0,20}$/]',
                            prompt: '(联系人)限20字'
                        }]
                },
                //邮箱
                email: {
                    identifier: 'email',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/]',
                        prompt: '请输入正确的邮箱格式'
                    },
                        {
                            type: 'regExp[/^.{0,30}$/]',
                            prompt: '(邮箱)限30字'
                        }]
                },
                //QQ
                staffQQ: {
                    identifier: 'qq',
                    optional: true,
                    rules: [{
                        type: 'empty',
                        prompt: '请输工作QQ'
                    },
                        {
                            type: 'regExp[/^[1-9]\\d{4,11}$/]',
                            prompt: '请输入正确的QQ格式'
                        }, {
                            type: 'regExp[/^.{0,20}$/]',
                            prompt: '(qq)限20字'
                        }]
                },
                //微信
                wechat: {
                    identifier: 'wechat',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(微信)限20字'
                    }]
                },
                //备注
                remark: {
                    identifier: 'remark',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[^]{0,100}$/]',
                        prompt: '(备注)限100字'
                    }]
                },
                //抬头名称
                headerName: {
                    identifier: 'headerName',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入抬头名称'
                    }, {
                        type: 'regExp[/^.{0,50}$/]',
                        prompt: '(抬头名称)限50字'
                    }]
                },
                //简称
                abbreName: {
                    identifier: 'abbreName',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入简称'
                    }, {
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(简称)限20字'
                    }]
                },
                //纳税识别号
                taxCode: {
                    identifier: 'taxCode',
                    rules: [{
                        type: 'empty',
                        prompt: '(纳税识别号)请输入纳税识别号'
                    },
                        {
                            type: 'regExp[/^[a-zA-Z0-9]{0,30}$/]',
                            prompt: '(纳税识别号)限30位数字或字母'
                        }]
                },
                //开户银行
                openBank: {
                    identifier: 'openBank',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(开户银行)限20字'
                    }]
                },
                //主管单位
                competentOrganization: {
                    identifier: 'competentOrganization',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(主管单位)限20字'
                    }]
                },
                //经费来源
                fundSources: {
                    identifier: 'fundSources',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(经费来源)限20字'
                    }]
                },
                //法人
                enterpriseLegalPerson: {
                    identifier: 'enterpriseLegalPerson',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(法人)限20字'
                    }]
                },
                //法人证书
                legalPersonCertificate: {
                    identifier: 'legalPersonCertificate',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^[a-zA-Z0-9]{15}$/]',
                        prompt: '(法人证书)15位数字或字母'
                    }]
                },
                //标签
                tag: {
                    identifier: 'tag',
                    rules: [{
                        type: 'empty',
                        prompt: '标签不能为空'
                    }]
                },
                //字号名称
                zhName: {
                    identifier: 'zhName',
                    optional: true,
                    rules: [{
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(字号名称)限20字'
                    }]
                }
            }
        });
    },
    //（一般纳税人）针对必填切换的表单验证器
    verifierForHeader : function (_selector) {
        /*Arg Guide
         @_selector: 对象选择器
         */
        $(_selector).form({
            on: 'blur',
            // inline: true,
            transition: 'fade',
            fields: {
                //抬头名称
                headerName: {
                    identifier: 'headerName',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入抬头名称'
                    }, {
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(抬头名称)限20字'
                    }]
                },
                //简称
                abbreName: {
                    identifier: 'abbreName',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入简称'
                    }, {
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(简称)限20字'
                    }]
                },
                //纳税识别号
                taxCode: {
                    identifier: 'taxCode',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入纳税识别号'
                    },
                        {
                            type: 'regExp[/^[a-zA-Z0-9]{0,30}$/]',
                            prompt: '(纳税识别号)限30位数字或字母'
                        }]
                },
                //开户银行
                openBank: {
                    identifier: 'openBank',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入开户银行'
                    }, {
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(开户银行)限20字'
                    }]
                },
                //银行账户
                accountBank: {
                    identifier: 'accountBank',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入银行账户'
                    }, {
                        type: 'regExp[/^\\d{16,19}$/]',
                        prompt: '(银行账户)限16到19位数字'
                    }]
                },
                //开户银行
                openBank: {
                    identifier: 'openBank',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入开户银行'
                    }, {
                        type: 'regExp[/^.{0,20}$/]',
                        prompt: '(开户银行)限20字'
                    }]
                },
                //注册地址
                registAddr: {
                    identifier: 'registAddr',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入注册地址'
                    }, {
                        type: 'regExp[/^.{0,50}$/]',
                        prompt: '(注册地址)限50字'
                    }]
                },
            }
        })
    },
    //表单验证出口
    checkform: function (ele) {
        /*Arg Guide
         @ ele 要验证的表单
         */
        $(ele).form('submit');
        return $(ele).hasClass('error');
    },
    //验证citypicker
    checkLocation: function (ele) {
        var locationInput;
        var locationBox;
        if ($(ele).is('.city-picker-input')) {
            locationInput = $(ele);
        } else {
            locationInput = $(ele).find('.city-picker-input');
        }
        locationBox = locationInput.parent('.field');
        if (locationBox.find('.city-picker-span .select-item').length == 2) {
            locationBox.removeClass('error')
            return true;
        } else {
            locationBox.addClass('error')
            return false;
        }
    },
    //上传文件
    uploadFile: function (body_ele, ele_trigger, ele_form, file_type) {
        /*Arg Guide
         @ trigger_id 触发按钮id(label)
         @ form_id 表单提交的id
         @ file_type 0:图片 1:pdf
         */
        if (file_type == 0) {
            $(body_ele).on('click', ele_trigger, function () {
                var $self = $(this);
                var input_name = $(this).attr('for');
                var $input_file = $('#' + input_name); //获取上传文件的input
                var maxSize = 2 * 1024 * 1024;//最大容量
                $input_file.off('change').change(function () {
                    var $iVal = $input_file.val();
                    if ($iVal) {
                        if (!($iVal.endsWith('jpg') || $iVal.endsWith('jpeg')
                            || $iVal.endsWith('png') || $iVal.endsWith('gif')
                            || $iVal.endsWith('bmp'))) {
                            layer.msg('请上传图片格式', {time: 1000})
                        } else {
                            if ($input_file[0].files[0].size > maxSize) {
                                layer.msg('上传图片不能超过2M', {time: 1000});
                                return false;
                            }
                            $(ele_form).ajaxSubmit({
                                type: 'POST',
                                success: function (result) {
                                    if (result.code == 0) {
                                        var filePath = result.data.filePath;
                                        /*var img = document.createElement('img');
                                        img.src = filePath;
                                        img.name = fileName;*/
                                        $self.siblings('input[type="hidden"]').val(filePath);
                                        $self.parent().find('img.e-show-pic').attr('src',filePath);
                                        // $self.parent().append($(img));//显示返回的图片
                                        $self.parent().addClass('hover-show');
                                        layer.msg('上传成功', {time: 1000});

                                        $self.parent().find('.zoom-label').off('click').click(
                                            function () {
                                                var _this = $(this)[0];
                                                Customer.openBigPic('#bigPicShowLayer',_this);
                                            });
                                        $input_file.val('');
                                    }
                                }
                            });
                        }
                    }
                })
            })
        } else if (file_type == 1) {
            $(body_ele).on('click', ele_trigger, function () {
                var $self = $(this);
                var input_name = $(this).attr('for');
                var $input_file = $('#' + input_name); //获取上传文件的input
                var maxSize = 2 * 1024 * 1024;//最大容量
                $input_file.off('change').change(function () {
                    var $iVal = $input_file.val();
                    if ($iVal) {
                        if (!$iVal.endsWith('pdf')) {
                            layer.msg('请上传pdf格式', {time: 1000})
                        } else {
                            if ($input_file[0].files[0].size > maxSize) {
                                layer.msg('上传pdf不能超过2M', {time: 1000});
                                return false;
                            }
                            $(ele_form).ajaxSubmit({
                                type: 'POST',
                                success: function (result) {
                                    if (result.code == 0) {
                                        var filePath = result.data.filePath;
                                        // var fileName = result.data.fileName;
                                        var img = document.createElement('img');
                                        img.className = 'pdficon';
                                        $self.siblings('input[type="hidden"]').val(filePath);
                                        $self.parent().find('img').hide();//隐藏上传提示图片
                                        $self.parent().append($(img));//显示返回的图片
                                        $self.parent().addClass('hover-show');
                                        layer.msg('上传成功', {time: 1000});
                                        $self.parent().find('.zoom-label').off('click').click(
                                            function () {
                                                window.open(filePath);
                                            });
                                        $input_file.val('');
                                    }
                                    else if (result.code == 9999) {
                                        layer.msg(result.msg, {time: 1000});
                                        wzERP.Common.TimeoutLogin();
                                        return false;
                                    }
                                }
                            });
                        }
                    }
                })
            })
        }
    },
    //上传pdf
    uploadFilePdf: function (body_ele, ele_trigger, ele_form) {
        /*Arg Guide
         @ trigger_id 触发按钮id(label)
         @ form_id 表单提交的id
         */
        $(body_ele).on('click', ele_trigger, function () {
            var $self = $(this);
            var input_name = $(this).attr('for');
            var $input_file = $('#' + input_name); //获取上传文件的input
            var maxSize = 2 * 1024 * 1024;//最大容量
            $input_file.off('change').change(function () {
                var $iVal = $input_file.val();
                if ($iVal) {
                    if (!$iVal.endsWith('pdf')) {
                        layer.msg('请上传pdf格式', {time: 1000})
                    } else {
                        if ($input_file[0].files[0].size > maxSize) {
                            layer.msg('上传pdf不能超过2M', {time: 1000});
                            return false;
                        }
                        $(ele_form).ajaxSubmit({
                            type: 'POST',
                            success: function (result) {
                                if (result.code == 0) {
                                    var filePath = result.data.filePath;
                                    var fileName = result.data.fileName;
                                    $self.text('重新上传证明');
                                    $self.siblings('a').remove('.seePdf')
                                    $self.parent().prepend(
                                        '<a class="ui blue button seePdf" href="' + filePath
                                        + '" style="display:inline-block" target="_blank">预览</a>');
                                    $self.siblings('input[type="hidden"]').val(filePath);
                                    $input_file.val('');
                                    layer.msg('上传成功!', {time: 1000});
                                }
                                else if (result.code == 9999) {
                                    layer.msg(result.msg, {time: 1000});
                                    wzERP.Common.TimeoutLogin();
                                    return false;
                                }
                            }
                        });
                    }
                }
            })
        })
    },
    //打开放大图
    openBigPic:function(_selector,e){
        /*Arg Guide
         @_selector: 对象选择器
         @_url: 图片地址
         */
        var _url = $(e).siblings('img.e-show-pic').attr('src');
        $(_selector).find('img').attr('src', _url);
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true,
            content: $(_selector)
        });
    },
    //vue 验证
    validate:function(validateObj,validateParam){
        //验证-S
        var canThrough = true;   //默认通过
        for(var i in validateParam){
            if(validateParam.hasOwnProperty(i)){
                var type = Object.prototype.toString.call(validateObj[i]).slice(8,-1);
                if(type == 'Array' && validateObj[i].length == 0 && !validateParam[i].canEmpty){
                    //数组判断
                    layer.msg(validateParam[i].msg,{time:1000})
                    canThrough = false;
                    break;
                }else if(type == 'String' && validateObj[i] == '' && !validateParam[i].canEmpty){
                    //字符串判断
                    layer.msg(validateParam[i].msg,{time:1000})
                    canThrough  = false;
                    break;
                }else if(type == 'Number' && validateObj[i] <0 && !validateParam[i].canEmpty){
                    //数字判断
                    layer.msg(validateParam[i].msg,{time:1000})
                    canThrough  = false;
                    break;
                }else if(type == 'Undefined' || type == 'Null' && !validateParam[i].canEmpty){
                    //无值判断
                    layer.msg(validateParam[i].msg,{time:1000})
                    canThrough  = false;
                    break;
                }
                //正则判断
                if(!!validateParam[i].regExp){
                    var regExp = new RegExp(validateParam[i].regExp);
                    if(!regExp.test(validateObj[i]) && !validateParam[i].canEmpty){
                        canThrough  = false;
                        layer.msg(validateParam[i].regExpMsg,{time:1000})
                        break;
                    }
                }
            }
        }
        return canThrough;
        //验证-E
    },
    //转时间辍为（格式2018-01-01）
    dateFormat:function(time,mode){
        /*Arg Guide
         @ time 时间辍
         */
        if (time == null) {
            return '';
        }
        var date = new Date(time);
        var year = date.getFullYear();
        var month = date.getMonth() + 1 >9 ? date.getMonth() + 1 : '0'+ (date.getMonth() + 1);
        var date = date.getDate() >9 ? date.getDate() : '0' + date.getDate();
        if(mode == 'm1'){
            //返回当前月第一天
            var date = '01';
        }
        return year + '-' + month + '-' + date
    },
    //清空pdf
    clearPdf:function(id){
        /*Arg Guide
         @ id label id
         */
        var $this = $('#'+id);
        var img = $this.siblings('img.pdficon');
        var defaultImg = $this.siblings('img.default-pic');
        $this.parent('.flex-item-fix').removeClass('hover-show');
        $this.siblings('input[type="hidden"]').val('');
        defaultImg.show();
        img.remove();
    },
    /*
     * 检测对象是否是空对象(不包含任何可读属性)。
     * 方法既检测对象本身的属性，也检测从原型继承的属性(因此没有使hasOwnProperty)。
     */
    isObjectEmpty:function(obj){
        for (var name in obj) {
            return false;
        }
        return true;
    },
    /*
     * 获取一个数组(arr1)的元素在另一个数组(arr2)里不存在的元素综合
     * return array
     */
    getSurplusElements: function(arr1,arr2){
        var arr = [];
        for(var i=0;i<arr2.length;i++){
            if(!VUE_UTIL.isInArray(arr1,arr2[i])){
                arr.push(arr2[i])
            }
        }
        return arr;
    },
    /*
     * 检测一个数组(arr1)的元素是否在另一个数组(arr2)里存在
     * 只要有一个存在返回true 否返回false
     */
    hasContainElement: function(arr1,arr2){
        var isExist = false;
        for(var i=0;i<arr1.length;i++){
            if(VUE_UTIL.isInArray(arr2,arr1[i])){
                isExist = true;
                break
            }
        }
        return isExist;
    }
}



